package org.frvi.goldspring.web.wicket.page;

import org.apache.wicket.authorization.strategies.role.Roles;
import org.apache.wicket.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.MarkupContainer;
import org.frvi.goldspring.business.entity.Account;

import java.util.List;
import java.util.ArrayList;

/**
 * User: Frank
 * Date: Oct 3, 2009
 * Time: 9:34:28 PM
 * To change this template use File | Settings | File Templates.
 */
@AuthorizeInstantiation(Roles.USER)
public class Overview extends WebPage {
    public Overview() {
        List<Account> accounts = getAccounts();            // replace by call to spring service
        if (accounts.size() == 0) {
            add(new NoAccountFragment("overview"));
        } else {
            add(new Label("overview", "accounts found, get overview panel"));
        }
    }

    private List<Account> getAccounts() {
        return new ArrayList<Account>();
    }

    // fragment for the situation of no accounts
    public class NoAccountFragment extends Fragment {

        public NoAccountFragment(String id) {
            super(id, "no_accounts", Overview.this);
        }
    }
}
